package com.smh.demo1.a11;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author shiminghui
 * @date 2025/4/16 16:54
 * @description: TODO
 */
public class A11Application {

    public static void main(String[] args) {

        Target target = new Target();

        Proxy proxy = new Proxy(new MethodInterceptor() {
            @Override
            public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
                System.out.println("代理类");
                // 利用jdk的反射
//                Object invoke = method.invoke(target, objects);
                // 不使用反射
                Object invoke = methodProxy.invoke(target, objects);
//                Object invoke = methodProxy.invokeSuper(o, objects);
                return invoke;
            }
        });
        proxy.read(3);

//        Proxy.newProxyInstance(A11Application.class.getClassLoader(), )


    }
}
